package com.hyl.controller;

import com.hyl.service.FileService;
import com.hyl.utils.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2023/7/6 11:39
 **/
@RestController
@RequestMapping("/api/oss/file")
public class OSSController {

	@Resource
	private FileService fileService;

	@PostMapping("/upload")
	public Result upload(@RequestParam("file") MultipartFile file,String module) {
		//返回上传到oss的路径
		String url = fileService.upload(file,module);
		return Result.ok(url).message("文件上传成功");
	}
}
